//
//  TalkView.m
//  map
//
//  Created by dllo on 16/4/26.
//  Copyright © 2016年 王彦森. All rights reserved.
//

#import "TalkView.h"

@interface TalkView ()
@property(nonatomic,strong)UITextField *draftTextField;
@property(nonatomic,strong)UIButton *sendBut;
@end

@implementation TalkView

-(id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self initView];
    }
    return self;
}


-(void)initView{
    [self setBackgroundColor:[UIColor colorWithWhite:0.9 alpha:1]];
    
    self.draftTextField = [[UITextField alloc]initWithFrame:CGRectMake(5, 5, self.frame.size.width-100, self.frame.size.height-10)
                           ];
    [self.draftTextField setBorderStyle:UITextBorderStyleRoundedRect];
    self.draftTextField.placeholder = @"谁最帅";
    self.draftTextField.font = [UIFont systemFontOfSize:13.0];
    [self addSubview:self.draftTextField];
    
    self.sendBut = [UIButton buttonWithType:UIButtonTypeCustom];
    self.sendBut.frame =CGRectMake(self.frame.size.width-90, 5, 85, self.frame.size.height-10);
    [self.sendBut setTitle:@"发送" forState:UIControlStateNormal];
    [self.sendBut addTarget:self action:@selector(sendBut:) forControlEvents:UIControlEventTouchUpInside];
    [self.layer setMasksToBounds:YES];
    self.sendBut.layer.cornerRadius = 4;
    [self addSubview:self.sendBut];

}

-(void)sendBut:(UIButton*)but{
    if (self.tablk) {
        self.tablk(self.draftTextField.text);
    }
self.draftTextField.text =@"";
}

-(NSString*)j{
    return _draftTextField.text;

}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.draftTextField resignFirstResponder];

}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
